/**
 * @Author: yishen@mdashen.com
 * @Date: 2021-03-08 12:34:04
 * @LastEditTime: 2021-03-08 16:47:51
 * @Description:
 */
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  mode: 'development', // production development
  entry: path.join(__dirname, 'src', 'index.js'),
  output: {
    filename: 'bundle.js',
    path: path.join(__dirname, 'dist'),
  },
  module: {
    rules: [
      {
        test: /\.js$/, // 符合此正则的走 babel-loader 插件
        loader: ['babel-loader'],
        include: path.join(__dirname, 'src'), // 此目录下的走 babel-loader 插件
        exclude: /node_modules/, // 排除此目录
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: path.join(__dirname, 'src', 'index.html'),
      filename: 'index.html', // 打包后的 dist 下的文件名
    }),
  ],
  devServer: {
    port: 3000,
    contentBase: path.join(__dirname, 'dist'),
  },
}
